﻿const storeBtn = document.getElementById('store-btn');
const retrBtn  = document.getElementById('retrieve-btn');

const userId = 'u123';
const user={
    name:'Max',
    age: 20,
    hobbies:['Cooking','Reading']
};

storeBtn.addEventListener('click',()=>{
   sessionStorage.setItem('uid',userId);
   localStorage.setItem('user',JSON.stringify(user));
});

retrBtn.addEventListener('click',()=>{
   const extractedId = sessionStorage.getItem('uid');
   const extractUser = JSON.parse(localStorage.getItem('user'));
   console.log(extractUser);
   if(extractedId){
       console.log('Got the id - ' + extractedId);
   }else{
       console.log('Could not find id.')
   }
});
